package com.example.netty.realNetty.eventLoop;

import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

@Slf4j
public class EventLoop {
    public static void main(String[] args) {
        EventLoopGroup eventExecutors = new NioEventLoopGroup(2);
        System.out.println(eventExecutors.next());
        System.out.println(eventExecutors.next());
        System.out.println(eventExecutors.next());
//        eventExecutors.next().submit(()->{
//            log.debug("哈哈哈");
//        });


//        eventExecutors.next().schedule(()->{
//            System.out.println("schedule");
//        },1,TimeUnit.SECONDS);
//      固定间隔时间执行
        eventExecutors.next().scheduleAtFixedRate(()->{
            System.out.println("scheduleWithFixedDelay");
        },1,2, TimeUnit.SECONDS);

//        scheduleWithFixedDelay 执行时间会加上线程阻塞时间
//        eventExecutors.next().scheduleWithFixedDelay(()->{
//            System.out.println("scheduleWithFixedDelay");
//        },1,2, TimeUnit.SECONDS);
//        log.debug("啦啦啦");
    }
}
